package task2;

import java.util.ArrayList;
import java.util.Scanner;

public class test2 {
    static Scanner input=new Scanner(System.in);
    static ArrayList<Integer> list=new ArrayList<>();
    public static void main(String[] args) {
        int length=input.nextInt();//长度

        for(int i=0;i<length;i++){//有序集合
            int element=input.nextInt();
            list.add(element);
        }
        int factor=input.nextInt();//待插入元素

        findKey(factor);
        print();
    }
    private static void findKey(int factor){
        int flag=0;

        if(factor>list.get(list.size()-1)){
            list.add(factor);
        } else {
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i) > factor) {
                    flag = i;
                    break;
                }
            }
            list.add(list.get(list.size()-1));
            for (int i =list.size()-1;i>flag; i--) {
                list.set(i, list.get(i-1));
            }
            list.set(flag, factor);
        }

    }
    private static void print(){
        for(Integer i:list){
            System.out.print(i+",");
        }
    }
}
